﻿using System;
using System.Collections.Generic;

namespace cz.zcu.PreSti.Components
{
    public class Splitter : RunnableComponent
    {
        #region Fields
        private string[] values = new string[4] { "1", "2", "3", "4"};
        private string inputValue = "";

        #endregion

        #region properties

        public virtual string[] Values
        {
            get
            {
                return values;
            }
            set
            {
                values = value;
            }
        }

        #endregion

        public Splitter(IPresentation p)
            : base(p, 1, 5, 1, 0)
        {
        }

        public override void trigIn(int n)
        {
            base.trigIn(n);
            int i = 0;
            foreach (string val in Values)
            {
                if (val == inputValue)
                {
                    trigOut(i);
                    return;
                }
                i++;
            }
            trigOut(4);
        }

        public override void setValueToSetter(int setterN, object value)
        {
            switch (setterN)
            {
                case 0:
                    convertValue(ref inputValue, value);
                    return;
            }
            base.setValueToSetter(setterN, value);
        }

        public override void update()
        {
        }

    }
}
